package icloud.com.myapplication;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import icloud.com.myapplication.db.DaoMaster;
import icloud.com.myapplication.db.DaoSession;

/**
 * 创建人：jinfangxing
 * 创建时间：2017/6/6
 * 功能描述：
 */

public class MyApplication extends Application {

    private DaoSession mDaoSession;
    
    private static MyApplication   instance;
    
    @Override
    public void onCreate() {
        super.onCreate();
        initGreenDao();
        instance=this;
    }

    public static MyApplication  getInstance(){
        return   instance;
    }
    
    /***
     * 
     */
    private void initGreenDao() {
        DaoMaster.DevOpenHelper  helper=new DaoMaster.DevOpenHelper(this,"test.db");
        SQLiteDatabase writableDatabase = helper.getWritableDatabase();
        DaoMaster  daoMaster=new DaoMaster(writableDatabase);
        mDaoSession=daoMaster.newSession();
    }

    public DaoSession getDaoSession() {
        return mDaoSession;
    }

    public void setDaoSession(DaoSession daoSession) {
        mDaoSession = daoSession;
    }
}
